﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SBLib.Common.CsvKS
{
    public class CustomObjectWriter : CsvBase
    {
        string filename = string.Empty;
        string delimiter = string.Empty;
        //List<T> customobject;

        public CustomObjectWriter(string FileName, string Delimiter)
            : base(FileName, Delimiter)
        {
            filename = FileName;
            delimiter = Delimiter;
        }

        protected override void ProcessObjectForWriting()
        {

        }

        protected override void ProcessObjectForWriting<T>(List<T> CustomObjectCollection)
        {

            foreach (T item in CustomObjectCollection)
            {
                //print column name
                _swFile.WriteLine(ConvertSingleObjectToDelimitedString<T>(item, false));
                break;
            }

            foreach (T item in CustomObjectCollection)
            {
                //values
                _swFile.WriteLine(ConvertSingleObjectToDelimitedString<T>(item, true));

            }
        }
    }
}
